package org.scala.javafx.rich

import javafx.beans.value.ObservableValue
import javafx.collections.ObservableList
import scala.reflect.Method
import org.scala.javafx.rich.Enrich._

case class Getter(item: Object, method: Method) {
}

case class RichObject(val item: Object) {
  def _class = item.getClass()
  def _get(name: String) = _class.getters("name")(item)()
  def _properties = this._class.properties.map { propertyMethod =>
    (propertyMethod.name -> propertyMethod.invoke(item).asInstanceOf[ObservableValue[Nothing]])
  }.toMap
  def _observableLists = this._class.observableLists.map { method =>
    println("==> observable list item found: " + method.name)
    (method.name -> method.invoke(item).asInstanceOf[ObservableList[Nothing]])
  }.toMap
}

object RichObject {
  /*class ClassInfo {
  }
  val classInfos = new Object() {
    val map = Map[Class[_], ClassInfo]()
    def apply(): ClassInfo
  }
  val getterMap = Map[String, Method]()
  
  def lookupGetter(_class: Class[_], name: String): Option[Method] = {
    this.synchronized {
      classes.get(_class) match {
        case x@Some(_) => x
        case None => None
      }
    }
  }*/
}
